package common.store.admin.contoller;

import common.store.admin.service.CategoryService;
import common.store.admin.service.SupplierService;
import common.store.admin.service.impl.CategoryServiceImpl;
import common.store.admin.service.impl.SupplierServiceImpl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/supplierUpdate")
public class SupplierUpdateServlet extends HttpServlet {
    SupplierService supplierService;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        supplierService = new SupplierServiceImpl();
        String sid = req.getParameter("sid");
        String sName = req.getParameter("sName");
        Integer rows = supplierService.updateSupplier(sid,sName);
        if(rows > 0){
            //刷新数据
            req.setAttribute("supplierList" , supplierService.getSupplierList());
            req.getRequestDispatcher("/admin/supplier/list.jsp").forward(req , resp);
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
